package com.wut.clock.factory.number;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


/**
 * @author ZYH
 * @unit D9Lab
 * @description 数字工厂
 * 获取用户的粉丝数、关注数、获赞数；
 * 获取文章的浏览量、点赞数、点踩数、评论数、收藏数；
 * 获取评论的点赞数、点踩数。
 * @date 2022/6/13 14:52
 */
@Component
public class NumberFactory {


    @Resource
    private BeanFactory beanFactory;

    /**
     * 获取数量的对象
     * @param numberType 类型 "user"/"article"/"comment" 不区分大小写
     * @return 实体对象
     */
    public Number getNumber(String numberType){
        if(numberType == null) return null;
        else if(numberType.equalsIgnoreCase("user")) return beanFactory.getBean(UserCount.class);
        else if(numberType.equalsIgnoreCase("article")) return beanFactory.getBean(ArticleCount.class);
        else if(numberType.equalsIgnoreCase("comment")) return beanFactory.getBean(CommentCount.class);
        else return null;
    }

}
